package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Datum;
import com.aaa.ssm.service.DatumService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;


@RestController
@RequestMapping("/datum")//父路径
public class DatumController extends BaseController{
    @Resource//依赖注入
    private DatumService datumService;
    /**
     * 分页带参查询
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Datum> page){
        return success(datumService.queryPage(page));
    }

    /**
     * 根据编号查询
     */
    @PostMapping("queryById")
    public Result queryById(Integer id){
        return success(datumService.queryById(id));
    }

    /**
     * 添加
     */
    @PostMapping("add")
    public Result add(@RequestBody Datum datum){
        return success(datumService.add(datum));
    }

    /**
     * 更新
     */
    @PostMapping("update")
    public Result update(@RequestBody Datum datum){
        return success(datumService.update(datum));
    }

    /**
     * 编号删除
     */
    @PostMapping("delete/{id}")
    public Result delete(@PathVariable("id")Integer id){
        return success(datumService.deleteById(id));
    }

}
